<?php
/**
 * @Author: liuhongbin
 * @Email: 514660094@qq.com
 * @Date: 2019-02-12 16:15:10
 * @Description:
 * @LastEditors: liuhongbin
 * @LastEditTime: xxx
 */

namespace addons\cloud_market\controller\api\developer;

use addons\cloud_market\controller\api\CloudMarketApiController;
use addons\cloud_market\model\CloudMarketDeveloper;

class User extends CloudMarketApiController
{
    protected $notApiCheck = '*';

    public function index()
    {
        $user = $this->getUser();
        return $this->success('ok', $user);
    }

    // 申请
    public function apply(){
        $user = $this->getUser();
        if($user->developer){
            if($user->developer['status'] == 0){
                return $this->error('你的申请正在审核中');
            }
            return $this->error('你已经申请过了，请勿重复申请');
        }
        $data = [
            'user_id' => $user->id,
            'status'  => 0,
            'type'   => input('type',0),
            'truename'   => input('truename',''),
            'phone' => input('phone',''),
            'company_code' => input('company_code',''),
            'is_student'=>input('is_student',0),
            'experience' => input('experience',''),
            'description'=>input('description',''),
            'rule' =>["developer","developer-setting"]
        ];
        CloudMarketDeveloper::create($data);
        return  $this->success('申请提交成功',input());
    }
}
